<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<%@ include file="/WEB-INF/jspf/meta/meta.jspf"%>
	<title>添加学生信息</title>
	<%@ include file="/WEB-INF/jspf/adminPage.jspf"%>
	<%@include file="/WEB-INF/jspf/css_js/easyui_grid_tools_js.jspf"%>
</head>
<body>
<%--<div style="margin: 20px 0;"></div>--%>
<%--<div class="easyui-panel" title="添加学生信息" style="width: 550px;overflow-y:auto">--%>
	<div style="padding: 0px auto;margin: 0px auto;width:800px;height:470px;overflow-x:auto;overflow-y:auto" >
		<form id="ff" method="post">
			<table cellpadding="5" ;style="text-align: center;">
				<tr>
					<td>学生编号:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentId" data-options="required:true"
							   style="width: 300px"></input></td>
					<td>学生姓名:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentName" data-options="required:true"
							   style="width: 300px"></input></td>
				</tr>
				<tr>
					<td>学生账号:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentAccount" data-options="required:true"
							   style="width: 300px"></input></td>
					<td>学生密码:</td>
					<td><input class="easyui-passwordbox" type="text"
							   name="studentPassword" value="12345678"
							   data-options="required:true" style="width: 300px"></input></td>
				</tr>
				<tr>
					<td colspan = "2">学生性别:&nbsp&nbsp&nbsp&nbsp&nbsp
						<input class="easyui-radiobutton" name="studentSex" id="studentSexDefaultValue" value="男" checked="checked" />&nbsp;男
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input class="easyui-radiobutton" name="studentSex" value="女">&nbsp;女
					</td>
				</tr>
				<tr>
					<td>学生邮箱:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentEmail"
							   data-options="required:false,validType:'email'"
							   style="width: 300px"></input></td>
					<td>学生电话:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentPhone" data-options="required:false"
							   style="width: 300px"></input></td>
				</tr>
				<tr>
					<td>学生生日:</td>
					<td><input name="studentBirthday" class="easyui-datebox" data-options="required:false" style="width: 300px"></td>
					<td>学生地址:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentAddr" data-options="required:true"
							   style="width: 300px"></input></td>
				</tr>
				<tr>
					<td>监护人电话:</td>
					<td><input class="easyui-textbox" type="text"
							   name="studentPhone2" data-options="required:true"
							   style="width: 300px"></input></td>
					<td>监护人姓名:</td>
					<td><input class="easyui-textbox" type="text" name="studentName2" data-options="required:true"
							   style="width: 300px"></input></td>
				</tr>
				<tr>
					<td>学生状态:</td>
					<td><input class="easyui-combobox" name="studentStyleId"
							   data-options="required:true,valueField:'studentStyleId',textField:'studentStyleName',editable:false,url:'<%=request.getContextPath()%>/student/studentStyleData.json'" />
					</td>
					<td>学生班级:</td>
					<td><input class="easyui-combobox" name="gradeId"
							   data-options="required:true,valueField:'gradeId',textField:'gradeName',editable:false,url:'<%=request.getContextPath()%>/student/gradeData.json'" />
					</td>
				</tr>
				<tr>
					<td>学生科目:</td>
					<td><input class="easyui-combobox" name="subjectId"
							   data-options="required:true,valueField:'subjectId',textField:'subjectName',editable:false,url:'<%=request.getContextPath()%>/student/subjectData.json'" />
					</td>
					<td>学生宿舍:</td>
					<td><input class="easyui-combobox" name="roomId"
							   data-options="required:true,valueField:'roomId',textField:'roomName',editable:false,url:'<%=request.getContextPath()%>/student/roomData.json'" />
					</td>
				</tr>

				<tr>
					<td>入学时间:</td>
					<td><input name="timeOfEnrollment" class="easyui-datebox" data-options="required:false" style="width: 300px"></td>
					</td>
					<td>招生老师:</td>
					<td><input class="easyui-combobox" name="teacherId"
							   data-options="valueField:'teacherId',textField:'teacherName',editable:false,url:'<%=request.getContextPath()%>/student/teacherData.json'" />
					</td>
				</tr>
			</table>
		</form>
		<div style="text-align: center;padding:0 auto">
			<a href="javascript:void(0)" class="easyui-linkbutton"
			   onclick="submitForm()">提交</a> <a href="javascript:void(0)"
												class="easyui-linkbutton" onclick="clearForm()">清除</a>
		</div>
<%--	</div>--%>
</div>
<script>
	function submitForm(){
		$('#ff').form({
			url:'<%=request.getContextPath()%>/student/addStu.json',
			onSubmit : function() {
				return $(this).form('validate');
			},
			success : function(data) {
				console.log(data);
				var d = typeof data == 'string' ? JSON.parse(data):data;
				$.messager.show({
					title:'操作提示',
					msg:d.msg,
					timeout:5000,
					showType:'slide'
				});
				if (d.msg!='数据重复'){
                    clearForm();
                }
            }
		})

		$('#ff').submit()
	}

	function clearForm() {
		$(".easyui-textbox").textbox('setValue','');
		$(".easyui-passwordbox").textbox('setValue','');
		$(".easyui-combobox").textbox('setValue','');
	}
</script>
</body>
</html>
